package fr.umlv.m2.jee.spij.persistence.schedule.dao;

import fr.umlv.m2.jee.spij.framework.dao.hibernate.AbstractHibernateDAO;
import fr.umlv.m2.jee.spij.persistence.schedule.ClassRoom;
import fr.umlv.m2.jee.spij.persistence.schedule.IClassRoomDAO;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 *
 */
@Repository("hibernateClassRoomDAO")
public class HibernateClassRoomDAO extends
        AbstractHibernateDAO<Long, ClassRoom> implements IClassRoomDAO {

    @Override
    public final List<ClassRoom> findByNbMinPlaces(final int nbMinPlaces) {
        Session session = getHibernateSession();
        Criteria criteria = session.createCriteria(ClassRoom.class);
        criteria.add(Restrictions.gt("nbPlace", nbMinPlaces));
        return criteria.list();
    }

}
